APE=/sys/src/ape
< $APE/config
<plan9/buildinfo
sourcedir = /sys/src/cmd/perl/$p9pvers
archname = plan9_$objtype
privlib=/sys/lib/perl
archlib = /$objtype/lib/perl/$p9pvers
sitelib = $privlib/site_perl
sitearch = $archlib/site_perl

CFLAGS =  -B  -D_POSIX_SOURCE -D_BSD_EXTENSION -DMY_UV_MAX=0x7fffffffUL
LDFLAGS = -B 

CCCMD = $CC  -c $CFLAGS 

perllib = $archlib/CORE/libperl.a

perlshr = $archlib/CORE/libperlshr.a

installman1dir = /sys/man/1
installman3dir = /sys/man/2

podnames = perl perlbook perldata perldebtut perldiag perldsc perlform perlfunc perlipc perllexwarn perllol perlmod perlmodlib perlmodinstall perlnewmod perlop perlootut perlopentut perlpacktut perlpod perlport perlrequick perlretut perlref perlreftut perlrequick perlrun perlsec perlstyle perlsub perlsyn perltie perltrap perlutil perlunifaq perluniintro perlvar
faqpodnames = perlfaq perlfaq1 perlfaq2 perlfaq3 perlfaq4 perlfaq5 perlfaq6 perlfaq7 perlfaq8 perlfaq9
advpodnames = perlapi perlapio perlcall perlclib perlcompile perldebguts perldbmfilter perldebug perldelta perldiag perlebcdic perlembed perlfilter perlfork perlguts perlhack perlintern perliol perllocale perlnumber perlobj perlpodspec perlre perlthrtut perltodo perlunicode perlunicook perlxs perlxs perlxstut
archpodnames = perlaix perlamiga perlbeos perlbs2000 perlce perlcygwin perldgux perldos perlfreebsd perlhpux perlhurd perlirix perlmacos perlmpeix perlnetware perlos2 perlos390 perlos400 perlplan9 perlqnx perlsolaris perltru64 perlvms perlvos perlwin32
histpods = perl5004delta perl5005delta perl561delta perl56delta perl570delta perl571delta perl572delta perl573delta perl58delta perlhist

libpods = ${podnames:%=pod/%.pod}

perlpods = $libpods

extensions = IO Socket Opcode DynaLoader Fcntl POSIX
ext_xs = IO.xs Socket.xs Opcode.xs  dl_none.xs Fcntl.xs POSIX.xs
ext_c = ${ext_xs:%.xs=%.c}
ext_obj = ${ext_xs:%.xs=%.$O}

obj = av.$O deb.$O doio.$O doop.$O dquote.$O dump.$O globals.$O gv.$O hv.$O locale.$O malloc.$O mathoms.$O mg.$O numeric.$O op.$O pad.$O perlapi.$O perlio.$O perly.$O pp.$O pp_ctl.$O pp_hot.$O pp_pack.$O pp_sort.$O pp_sys.$O reentr.$O regcomp.$O regexec.$O run.$O scope.$O sv.$O taint.$O time64.$O toke.$O universal.$O utf8.$O util.$O

OBJS = perl.$O plan9.$O $obj

testlist = base/*.t comp/*.t cmd/*.t io/*.t op/*.t

install:V:	perl preplibrary 
		cp perl /$objtype/bin/perl
		cp plan9/aperl /rc/bin/Perl
		mk man
		
perl:		config.h miniperlmain.$O miniperl $archlib/Config.pm perlmain.$O $perlshr 
		$LD $CFLAGS -o perl perlmain.$O $perllib $perlshr
		
miniperl:	config.h $perllib miniperlmain.$O 
		$LD  $CFLAGS -o miniperl miniperlmain.$O  $perllib 

preplibrary:V:	miniperl $archlib/Config.pm
			cd $privlib
			for (file in *.pm */*.pm $archlib/Config.pm) $sourcedir/miniperl  -e 'use AutoSplit; autosplit(@ARGV)' $file $privlib/auto
	
$perllib(%):N:	%
$perllib: ${OBJS:%=$perllib(%)}
		ar rv $perllib $OBJS
		$RANLIB $perllib
			
miniperlmain.$O:	config.h 
				$CCCMD miniperlmain.c

perlmain.$O:	config.h perlmain.c
			$CCCMD perlmain.c

perlmain.c:	miniperl vms/writemain.pl
			./miniperl vms/writemain.pl $extensions

config.h:		plan9/fndvers
			plan9/fndvers 
			cp config.h $archlib/CORE

$perlshr(%):N:	%
$perlshr:  ${ext_obj:%=$perlshr(%)}
		ar rv $perlshr $ext_obj
		$RANLIB $perlshr

IO.c:		miniperl ext/IO/IO.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/IO/IO.xs > $target
			cp ext/IO/*.pm $privlib
			if (test !-d $privlib/IO) { 
			mkdir $privlib/IO
			cp ext/IO/lib/IO/*.pm $privlib/IO
			 }

Socket.$O:	config.h Socket.c
			$CCCMD -I plan9 Socket.c

Socket.c:		miniperl ext/Socket/Socket.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/Socket/Socket.xs > $target
			cp ext/Socket/Socket.pm $privlib

Opcode.c:		miniperl ext/Opcode/Opcode.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/Opcode/Opcode.xs > $target
			cp ext/Opcode/*.pm $privlib

Fcntl.c:		miniperl ext/Fcntl/Fcntl.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/Fcntl/Fcntl.xs > $target
			cp ext/Fcntl/Fcntl.pm $privlib

POSIX.c:		miniperl ext/POSIX/POSIX.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/POSIX/POSIX.xs > $target
			cp ext/POSIX/POSIX.pm $privlib

dl_none.c:	miniperl ext/DynaLoader/dl_none.xs
			./miniperl $privlib/ExtUtils/xsubpp -noprototypes -typemap $privlib/ExtUtils/typemap ext/DynaLoader/dl_none.xs > $target
			cp ext/DynaLoader/DynaLoader.pm $privlib

test:V:		
			bind -b $privlib $sourcedir/lib
			bind -b $archlib $sourcedir/lib
			cd $sourcedir/t
			rm -f perl
			cp /$objtype/bin/perl $sourcedir/t
			perl TEST `{ ls */*.t | comm -23 - ../plan9/exclude }

plan9.$O:	config.h ./plan9/plan9.c
			cp ./plan9/plan9.c ./plan9.c
			$CCCMD plan9.c

%.$O:	config.h %.c
		$CCCMD $stem.c

$archlib/Config.pm:		miniperl config.sh
				./miniperl configpm $archlib/Config.pm

config.sh:	miniperl config.h
		./miniperl ./plan9/genconfig.pl

installall:V:	
			for (objtype in 386 mips 68020 sparc) mk install

man:V:		$perlpods pod/pod2man.PL perl
			perl pod/pod2man.PL
			for (i in $podnames) pod/pod2man pod/$i.pod > $installman3dir/$i
			for (i in $faqpodnames) pod/pod2man pod/$i.pod > $installman3dir/$i
			for (i in $advpodnames) pod/pod2man pod/$i.pod > $installman3dir/$i
			for (i in $archpodnames) pod/pod2man pod/$i.pod > $installman3dir/$i
			for (i in $histpodnames) pod/pod2man pod/$i.pod > $installman3dir/$i
			
nuke clean:V:	
		rm -f *.$O   $extensions^.pm config.sh $perllib config.h $perlshr perlmain.c perl miniperl $archlib/Config.pm $ext_c
		rm -rf $privlib/IO

deleteman:V:
			rm -f $installman1dir/perl* $installman3dir/perl*
